package com.xbongbong.paas.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;

/**
 * @author: wufeng
 * @date: 2018/11/22 14:09
 * @desrcption: 可选范围枚举类
 */
public enum OptionalRangeEnum {

    DEPT("dept", "enum.optionalRange.memo.dept"),
    ROLE("role", "enum.optionalRange.memo.role"),
    MANAGER("manager", "enum.optionalRange.memo.manager"),
    USER("user", "enum.optionalRange.memo.user"),
    DYNAMIC("dynamic", "enum.optionalRange.memo.dynamic"),
    DYNAMIC_MANAGER("dynamicManager", "enum.optionalRange.memo.dynamic_manager"),
    /**
     * 工作流动态负责人
     */
    WORKFLOW_DYNAMIC_MANAGER("workflowDynamicManager", "enum.optionalRange.memo.dynamic_manager"),
    ;

    private String value;

    private String memo;
    OptionalRangeEnum(String value, String memo) {
        this.value = value;
        this.memo = memo;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public String getMemo() {
        return I18nMessageUtil.getMessage(memo);
    }

    public void setMemo(String memo) {
        this.memo = memo;
    }

    public static OptionalRangeEnum getByValue(String value) {
        if(value == null) {
            return null;
        }
        for (OptionalRangeEnum cacheCode : values()) {
            if (value.equals(cacheCode.getValue())) {
                return cacheCode;
            }
        }
        return null;
    }
}
